{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# 使用 TEDD 进行可视化\n",
        "\n",
        "**原作者**: [Yongfeng Gu](https://github.com/yongfeng-nv)\n",
        "\n",
        "这是关于使用 TEDD (Tensor Expression Debug Display) 可视化张量表达式的介绍。\n",
        "\n",
        "张量表达式使用原语(primitive)调度。尽管单个原语通常很容易理解，但当您将它们放在一起时，它们很快就变得复杂了。在张量表达式中引入了调度原语的运算模型 (operational model)。\n",
        "\n",
        "- 不同调度原语之间的交互，\n",
        "- 调度原语对最终代码生成(code generation)的影响。\n",
        "\n",
        "运算模型基于数据流图(Dataflow Graph)、调度树(Schedule Tree)和迭代关系图(IterVar Relationship Graph)。调度原语对这些图执行运算。\n",
        "\n",
        "TEDD 根据给定的调度呈现这三个图。本教程演示了如何使用 TEDD 以及如何解释呈现的图。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import tvm\n",
        "from tvm import te\n",
        "from tvm import topi\n",
        "from tvm.contrib import tedd\n",
        "from IPython.display import display_svg"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 定义和调度带有 bias 和 ReLU 的卷积\n",
        "\n",
        "建立包含 Bias 和 ReLU 的卷积张量表达式的例子。首先连接 conv2d、add 和 relu TOPIs。然后，创建 TOPI 通用调度。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "batch = 1\n",
        "in_channel = 256\n",
        "in_size = 32\n",
        "num_filter = 256\n",
        "kernel = 3\n",
        "stride = 1\n",
        "padding = \"SAME\"\n",
        "dilation = 1\n",
        "\n",
        "A = te.placeholder((in_size, in_size, in_channel, batch), name=\"A\")\n",
        "W = te.placeholder((kernel, kernel, in_channel, num_filter), name=\"W\")\n",
        "B = te.placeholder((1, num_filter, 1), name=\"bias\")\n",
        "\n",
        "with tvm.target.Target(\"llvm\"):\n",
        "    t_conv = topi.nn.conv2d_hwcn(A, W, stride, padding, dilation)\n",
        "    t_bias = topi.add(t_conv, B)\n",
        "    t_relu = topi.nn.relu(t_bias)\n",
        "    s = topi.generic.schedule_conv2d_hwcn([t_relu])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 使用 TEDD 渲染 Graph\n",
        "\n",
        "渲染图来查看计算过程以及如何调度它。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 3,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "image/svg+xml": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"1682pt\" height=\"142pt\" viewBox=\"0.00 0.00 1681.82 142.21\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 138.21)\">\n<title>Dataflow Graph</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-138.21 1677.82,-138.21 1677.82,4 -4,4\"/>\n<!-- Stage_0 -->\n<g id=\"node1\" class=\"node\">\n<title>Stage_0</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"0,-93 0,-133 10,-133 10,-93 0,-93\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"0,-93 0,-133 10,-133 10,-93 0,-93\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"10,-93 10,-133 72,-133 72,-93 10,-93\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"10,-93 10,-133 72,-133 72,-93 10,-93\"/>\n<text text-anchor=\"start\" x=\"36\" y=\"-116.8\" font-family=\"Times,serif\" font-size=\"14.00\">A</text>\n<text text-anchor=\"start\" x=\"15\" y=\"-101.8\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"72,-93 72,-133 92,-133 92,-93 72,-93\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"72,-93 72,-133 92,-133 92,-93 72,-93\"/>\n<text text-anchor=\"start\" x=\"77\" y=\"-109.3\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n</g>\n<!-- Tensor_0_0 -->\n<g id=\"node2\" class=\"node\">\n<title>Tensor_0_0</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"205.78\" cy=\"-113\" rx=\"77.56\" ry=\"21.43\"/>\n<text text-anchor=\"middle\" x=\"205.78\" y=\"-116.8\" font-family=\"Times,serif\" font-size=\"14.00\">[32, 32, 256, 1]</text>\n<text text-anchor=\"middle\" x=\"205.78\" y=\"-101.8\" font-family=\"Times,serif\" font-size=\"14.00\">float32</text>\n</g>\n<!-- Stage_0&#45;&gt;Tensor_0_0 -->\n<g id=\"edge1\" class=\"edge\">\n<title>Stage_0:O_0-&gt;Tensor_0_0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M92,-113C100.3,-113 108.95,-113 117.6,-113\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"117.73,-116.5 127.73,-113 117.73,-109.5 117.73,-116.5\"/>\n</g>\n<!-- Stage_1 -->\n<g id=\"node3\" class=\"node\">\n<title>Stage_1</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"319.56,-93 319.56,-133 339.56,-133 339.56,-93 319.56,-93\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"319.56,-93 319.56,-133 339.56,-133 339.56,-93 319.56,-93\"/>\n<text text-anchor=\"start\" x=\"324.56\" y=\"-109.3\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"339.56,-93 339.56,-133 419.56,-133 419.56,-93 339.56,-93\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"339.56,-93 339.56,-133 419.56,-133 419.56,-93 339.56,-93\"/>\n<text text-anchor=\"start\" x=\"344.56\" y=\"-116.8\" font-family=\"Times,serif\" font-size=\"14.00\">pad_temp</text>\n<text text-anchor=\"start\" x=\"353.56\" y=\"-101.8\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"419.56,-93 419.56,-133 439.56,-133 439.56,-93 419.56,-93\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"419.56,-93 419.56,-133 439.56,-133 439.56,-93 419.56,-93\"/>\n<text text-anchor=\"start\" x=\"424.56\" y=\"-109.3\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n</g>\n<!-- Tensor_0_0&#45;&gt;Stage_1 -->\n<g id=\"edge2\" class=\"edge\">\n<title>Tensor_0_0-&gt;Stage_1:I_0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M283.83,-113C292.34,-113 300.97,-113 309.4,-113\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"309.56,-116.5 319.56,-113 309.56,-109.5 309.56,-116.5\"/>\n</g>\n<!-- Tensor_1_0 -->\n<g id=\"node4\" class=\"node\">\n<title>Tensor_1_0</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"553.35\" cy=\"-113\" rx=\"77.56\" ry=\"21.43\"/>\n<text text-anchor=\"middle\" x=\"553.35\" y=\"-116.8\" font-family=\"Times,serif\" font-size=\"14.00\">[34, 34, 256, 1]</text>\n<text text-anchor=\"middle\" x=\"553.35\" y=\"-101.8\" font-family=\"Times,serif\" font-size=\"14.00\">float32</text>\n</g>\n<!-- Stage_1&#45;&gt;Tensor_1_0 -->\n<g id=\"edge3\" class=\"edge\">\n<title>Stage_1:O_0-&gt;Tensor_1_0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M439.56,-113C447.87,-113 456.51,-113 465.16,-113\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"465.3,-116.5 475.3,-113 465.3,-109.5 465.3,-116.5\"/>\n</g>\n<!-- Stage_3 -->\n<g id=\"node7\" class=\"node\">\n<title>Stage_3</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"667.13,-83 667.13,-108 687.13,-108 687.13,-83 667.13,-83\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"667.13,-83 667.13,-108 687.13,-108 687.13,-83 667.13,-83\"/>\n<text text-anchor=\"start\" x=\"672.13\" y=\"-91.8\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"687.13,-58 687.13,-108 793.13,-108 793.13,-58 687.13,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"687.13,-58 687.13,-108 793.13,-108 793.13,-58 687.13,-58\"/>\n<text text-anchor=\"start\" x=\"692.13\" y=\"-86.8\" font-family=\"Times,serif\" font-size=\"14.00\">conv2d_hwcn</text>\n<text text-anchor=\"start\" x=\"714.13\" y=\"-71.8\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"793.13,-83 793.13,-108 813.13,-108 813.13,-83 793.13,-83\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"793.13,-83 793.13,-108 813.13,-108 813.13,-83 793.13,-83\"/>\n<text text-anchor=\"start\" x=\"798.13\" y=\"-91.8\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"667.13,-58 667.13,-83 687.13,-83 687.13,-58 667.13,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"667.13,-58 667.13,-83 687.13,-83 687.13,-58 667.13,-58\"/>\n<text text-anchor=\"start\" x=\"672.13\" y=\"-66.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"793.13,-58 793.13,-83 813.13,-83 813.13,-58 793.13,-58\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"793.13,-58 793.13,-83 813.13,-83 813.13,-58 793.13,-58\"/>\n</g>\n<!-- Tensor_1_0&#45;&gt;Stage_3 -->\n<g id=\"edge5\" class=\"edge\">\n<title>Tensor_1_0-&gt;Stage_3:I_0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M615.85,-100.33C629.05,-98.36 643.15,-96.78 656.8,-96.22\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"657.2,-99.71 667.13,-96 657.05,-92.71 657.2,-99.71\"/>\n</g>\n<!-- Stage_2 -->\n<g id=\"node5\" class=\"node\">\n<title>Stage_2</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"333.56,-33 333.56,-73 343.56,-73 343.56,-33 333.56,-33\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"333.56,-33 333.56,-73 343.56,-73 343.56,-33 333.56,-33\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"343.56,-33 343.56,-73 405.56,-73 405.56,-33 343.56,-33\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"343.56,-33 343.56,-73 405.56,-73 405.56,-33 343.56,-33\"/>\n<text text-anchor=\"start\" x=\"367.06\" y=\"-56.8\" font-family=\"Times,serif\" font-size=\"14.00\">W</text>\n<text text-anchor=\"start\" x=\"348.56\" y=\"-41.8\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"405.56,-33 405.56,-73 425.56,-73 425.56,-33 405.56,-33\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"405.56,-33 405.56,-73 425.56,-73 425.56,-33 405.56,-33\"/>\n<text text-anchor=\"start\" x=\"410.56\" y=\"-49.3\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n</g>\n<!-- Tensor_2_0 -->\n<g id=\"node6\" class=\"node\">\n<title>Tensor_2_0</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"553.35\" cy=\"-53\" rx=\"77.56\" ry=\"21.43\"/>\n<text text-anchor=\"middle\" x=\"553.35\" y=\"-56.8\" font-family=\"Times,serif\" font-size=\"14.00\">[3, 3, 256, 256]</text>\n<text text-anchor=\"middle\" x=\"553.35\" y=\"-41.8\" font-family=\"Times,serif\" font-size=\"14.00\">float32</text>\n</g>\n<!-- Stage_2&#45;&gt;Tensor_2_0 -->\n<g id=\"edge4\" class=\"edge\">\n<title>Stage_2:O_0-&gt;Tensor_2_0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M426.56,-53C439.06,-53 452.25,-53 465.2,-53\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"465.52,-56.5 475.52,-53 465.52,-49.5 465.52,-56.5\"/>\n</g>\n<!-- Tensor_2_0&#45;&gt;Stage_3 -->\n<g id=\"edge6\" class=\"edge\">\n<title>Tensor_2_0-&gt;Stage_3:I_1</title>\n<path fill=\"none\" stroke=\"black\" d=\"M615.85,-65.67C629.05,-67.64 643.15,-69.22 656.8,-69.78\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"657.05,-73.29 667.13,-70 657.2,-66.29 657.05,-73.29\"/>\n</g>\n<!-- Tensor_3_0 -->\n<g id=\"node8\" class=\"node\">\n<title>Tensor_3_0</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"926.91\" cy=\"-92\" rx=\"77.56\" ry=\"21.43\"/>\n<text text-anchor=\"middle\" x=\"926.91\" y=\"-95.8\" font-family=\"Times,serif\" font-size=\"14.00\">[32, 32, 256, 1]</text>\n<text text-anchor=\"middle\" x=\"926.91\" y=\"-80.8\" font-family=\"Times,serif\" font-size=\"14.00\">float32</text>\n</g>\n<!-- Stage_3&#45;&gt;Tensor_3_0 -->\n<g id=\"edge7\" class=\"edge\">\n<title>Stage_3:O_0-&gt;Tensor_3_0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M813.13,-96C821.81,-96 830.87,-95.88 839.91,-95.68\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"840.18,-99.18 850.09,-95.43 840,-92.18 840.18,-99.18\"/>\n</g>\n<!-- Stage_5 -->\n<g id=\"node11\" class=\"node\">\n<title>Stage_5</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"1040.69,-60 1040.69,-85 1060.69,-85 1060.69,-60 1040.69,-60\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1040.69,-60 1040.69,-85 1060.69,-85 1060.69,-60 1040.69,-60\"/>\n<text text-anchor=\"start\" x=\"1045.69\" y=\"-68.8\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"1060.69,-35 1060.69,-85 1122.69,-85 1122.69,-35 1060.69,-35\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1060.69,-35 1060.69,-85 1122.69,-85 1122.69,-35 1060.69,-35\"/>\n<text text-anchor=\"start\" x=\"1070.19\" y=\"-63.8\" font-family=\"Times,serif\" font-size=\"14.00\">T_add</text>\n<text text-anchor=\"start\" x=\"1065.69\" y=\"-48.8\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"1122.69,-60 1122.69,-85 1142.69,-85 1142.69,-60 1122.69,-60\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1122.69,-60 1122.69,-85 1142.69,-85 1142.69,-60 1122.69,-60\"/>\n<text text-anchor=\"start\" x=\"1127.69\" y=\"-68.8\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"1040.69,-35 1040.69,-60 1060.69,-60 1060.69,-35 1040.69,-35\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1040.69,-35 1040.69,-60 1060.69,-60 1060.69,-35 1040.69,-35\"/>\n<text text-anchor=\"start\" x=\"1045.69\" y=\"-43.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"1122.69,-35 1122.69,-60 1142.69,-60 1142.69,-35 1122.69,-35\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1122.69,-35 1122.69,-60 1142.69,-60 1142.69,-35 1122.69,-35\"/>\n</g>\n<!-- Tensor_3_0&#45;&gt;Stage_5 -->\n<g id=\"edge9\" class=\"edge\">\n<title>Tensor_3_0-&gt;Stage_5:I_0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M986.71,-78.29C1000.76,-75.86 1015.95,-73.89 1030.63,-73.23\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"1030.77,-76.73 1040.69,-73 1030.61,-69.73 1030.77,-76.73\"/>\n</g>\n<!-- Stage_4 -->\n<g id=\"node9\" class=\"node\">\n<title>Stage_4</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"694.13,0 694.13,-40 704.13,-40 704.13,0 694.13,0\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"694.13,0 694.13,-40 704.13,-40 704.13,0 694.13,0\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"704.13,0 704.13,-40 766.13,-40 766.13,0 704.13,0\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"704.13,0 704.13,-40 766.13,-40 766.13,0 704.13,0\"/>\n<text text-anchor=\"start\" x=\"720.13\" y=\"-23.8\" font-family=\"Times,serif\" font-size=\"14.00\">bias</text>\n<text text-anchor=\"start\" x=\"709.13\" y=\"-8.8\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"766.13,0 766.13,-40 786.13,-40 786.13,0 766.13,0\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"766.13,0 766.13,-40 786.13,-40 786.13,0 766.13,0\"/>\n<text text-anchor=\"start\" x=\"771.13\" y=\"-16.3\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n</g>\n<!-- Tensor_4_0 -->\n<g id=\"node10\" class=\"node\">\n<title>Tensor_4_0</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"926.91\" cy=\"-28\" rx=\"52.15\" ry=\"21.43\"/>\n<text text-anchor=\"middle\" x=\"926.91\" y=\"-31.8\" font-family=\"Times,serif\" font-size=\"14.00\">[1, 256, 1]</text>\n<text text-anchor=\"middle\" x=\"926.91\" y=\"-16.8\" font-family=\"Times,serif\" font-size=\"14.00\">float32</text>\n</g>\n<!-- Stage_4&#45;&gt;Tensor_4_0 -->\n<g id=\"edge8\" class=\"edge\">\n<title>Stage_4:O_0-&gt;Tensor_4_0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M787.13,-20C812.78,-20 841.07,-21.38 865.37,-22.99\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"865.3,-26.5 875.52,-23.7 865.78,-19.51 865.3,-26.5\"/>\n</g>\n<!-- Tensor_4_0&#45;&gt;Stage_5 -->\n<g id=\"edge10\" class=\"edge\">\n<title>Tensor_4_0-&gt;Stage_5:I_1</title>\n<path fill=\"none\" stroke=\"black\" d=\"M972.08,-38.94C989.79,-42.56 1010.7,-45.88 1030.67,-46.77\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"1030.61,-50.27 1040.69,-47 1030.77,-43.27 1030.61,-50.27\"/>\n</g>\n<!-- Tensor_5_0 -->\n<g id=\"node12\" class=\"node\">\n<title>Tensor_5_0</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"1256.47\" cy=\"-73\" rx=\"77.56\" ry=\"21.43\"/>\n<text text-anchor=\"middle\" x=\"1256.47\" y=\"-76.8\" font-family=\"Times,serif\" font-size=\"14.00\">[32, 32, 256, 1]</text>\n<text text-anchor=\"middle\" x=\"1256.47\" y=\"-61.8\" font-family=\"Times,serif\" font-size=\"14.00\">float32</text>\n</g>\n<!-- Stage_5&#45;&gt;Tensor_5_0 -->\n<g id=\"edge11\" class=\"edge\">\n<title>Stage_5:O_0-&gt;Tensor_5_0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M1142.69,-73C1150.99,-73 1159.64,-73 1168.29,-73\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"1168.42,-76.5 1178.42,-73 1168.42,-69.5 1168.42,-76.5\"/>\n</g>\n<!-- Stage_6 -->\n<g id=\"node13\" class=\"node\">\n<title>Stage_6</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"1370.25,-53 1370.25,-93 1390.25,-93 1390.25,-53 1370.25,-53\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1370.25,-53 1370.25,-93 1390.25,-93 1390.25,-53 1370.25,-53\"/>\n<text text-anchor=\"start\" x=\"1375.25\" y=\"-69.3\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"1390.25,-53 1390.25,-93 1462.25,-93 1462.25,-53 1390.25,-53\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1390.25,-53 1390.25,-93 1462.25,-93 1462.25,-53 1390.25,-53\"/>\n<text text-anchor=\"start\" x=\"1395.25\" y=\"-76.8\" font-family=\"Times,serif\" font-size=\"14.00\">compute</text>\n<text text-anchor=\"start\" x=\"1400.25\" y=\"-61.8\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"1462.25,-53 1462.25,-93 1482.25,-93 1482.25,-53 1462.25,-53\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1462.25,-53 1462.25,-93 1482.25,-93 1482.25,-53 1462.25,-53\"/>\n<text text-anchor=\"start\" x=\"1467.25\" y=\"-69.3\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n</g>\n<!-- Tensor_5_0&#45;&gt;Stage_6 -->\n<g id=\"edge12\" class=\"edge\">\n<title>Tensor_5_0-&gt;Stage_6:I_0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M1334.52,-73C1343.03,-73 1351.66,-73 1360.09,-73\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"1360.25,-76.5 1370.25,-73 1360.25,-69.5 1360.25,-76.5\"/>\n</g>\n<!-- Tensor_6_0 -->\n<g id=\"node14\" class=\"node\">\n<title>Tensor_6_0</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"1596.04\" cy=\"-73\" rx=\"77.56\" ry=\"21.43\"/>\n<text text-anchor=\"middle\" x=\"1596.04\" y=\"-76.8\" font-family=\"Times,serif\" font-size=\"14.00\">[32, 32, 256, 1]</text>\n<text text-anchor=\"middle\" x=\"1596.04\" y=\"-61.8\" font-family=\"Times,serif\" font-size=\"14.00\">float32</text>\n</g>\n<!-- Stage_6&#45;&gt;Tensor_6_0 -->\n<g id=\"edge13\" class=\"edge\">\n<title>Stage_6:O_0-&gt;Tensor_6_0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M1482.25,-73C1490.56,-73 1499.2,-73 1507.85,-73\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"1507.99,-76.5 1517.99,-73 1507.99,-69.5 1507.99,-76.5\"/>\n</g>\n</g>\n</svg>",
            "text/plain": [
              "<IPython.core.display.SVG object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "graph = tedd.viz_dataflow_graph(s, show_svg=True)\n",
        "display_svg(graph)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "也可保存图到本地:\n",
        "\n",
        "```python\n",
        "tedd.viz_dataflow_graph(s, dot_file_path=\"/tmp/dfg.dot\")\n",
        "```"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "第一个是数据流图。每个节点表示一个阶段，中间显示名称和 memory scope，两侧显示 inputs/outputs 信息。边表示节点的依赖关系。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "image/svg+xml": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"1402pt\" height=\"575pt\" viewBox=\"0.00 0.00 1402.00 575.00\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 571)\">\n<title>Schedule Tree</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-571 1398,-571 1398,4 -4,4\"/>\n<g id=\"clust1\" class=\"cluster\">\n<title>cluster_legend</title>\n<polygon fill=\"none\" stroke=\"black\" points=\"8,-104 8,-368 152,-368 152,-104 8,-104\"/>\n<text text-anchor=\"middle\" x=\"80\" y=\"-111.8\" font-family=\"Times,serif\" font-size=\"14.00\">Legend</text>\n</g>\n<!-- legend -->\n<g id=\"node1\" class=\"node\">\n<title>legend</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"17,-334.5 17,-359.5 27,-359.5 27,-334.5 17,-334.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-334.5 17,-359.5 27,-359.5 27,-334.5 17,-334.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-334.5 27,-359.5 144,-359.5 144,-334.5 27,-334.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-334.5 27,-359.5 144,-359.5 144,-334.5 27,-334.5\"/>\n<text text-anchor=\"start\" x=\"52\" y=\"-343.3\" font-family=\"Times,serif\" font-size=\"14.00\">kDataPar</text>\n<polygon fill=\"#2980b9\" stroke=\"transparent\" points=\"17,-309.5 17,-334.5 27,-334.5 27,-309.5 17,-309.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-309.5 17,-334.5 27,-334.5 27,-309.5 17,-309.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-309.5 27,-334.5 144,-334.5 144,-309.5 27,-309.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-309.5 27,-334.5 144,-334.5 144,-309.5 27,-309.5\"/>\n<text text-anchor=\"start\" x=\"36\" y=\"-318.3\" font-family=\"Times,serif\" font-size=\"14.00\">kThreadIndex</text>\n<polygon fill=\"#fad7a0\" stroke=\"transparent\" points=\"17,-284.5 17,-309.5 27,-309.5 27,-284.5 17,-284.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-284.5 17,-309.5 27,-309.5 27,-284.5 17,-284.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-284.5 27,-309.5 144,-309.5 144,-284.5 27,-284.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-284.5 27,-309.5 144,-309.5 144,-284.5 27,-284.5\"/>\n<text text-anchor=\"start\" x=\"32\" y=\"-293.3\" font-family=\"Times,serif\" font-size=\"14.00\">kCommReduce</text>\n<polygon fill=\"#d35400\" stroke=\"transparent\" points=\"17,-259.5 17,-284.5 27,-284.5 27,-259.5 17,-259.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-259.5 17,-284.5 27,-284.5 27,-259.5 17,-259.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-259.5 27,-284.5 144,-284.5 144,-259.5 27,-259.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-259.5 27,-284.5 144,-284.5 144,-259.5 27,-259.5\"/>\n<text text-anchor=\"start\" x=\"51.5\" y=\"-268.3\" font-family=\"Times,serif\" font-size=\"14.00\">kOrdered</text>\n<polygon fill=\"#abb2b9\" stroke=\"transparent\" points=\"17,-234.5 17,-259.5 27,-259.5 27,-234.5 17,-234.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-234.5 17,-259.5 27,-259.5 27,-234.5 17,-234.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-234.5 27,-259.5 144,-259.5 144,-234.5 27,-234.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-234.5 27,-259.5 144,-259.5 144,-234.5 27,-234.5\"/>\n<text text-anchor=\"start\" x=\"53.5\" y=\"-243.3\" font-family=\"Times,serif\" font-size=\"14.00\">kOpaque</text>\n<polygon fill=\"#d2b4de\" stroke=\"transparent\" points=\"17,-209.5 17,-234.5 27,-234.5 27,-209.5 17,-209.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-209.5 17,-234.5 27,-234.5 27,-209.5 17,-209.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-209.5 27,-234.5 144,-234.5 144,-209.5 27,-209.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-209.5 27,-234.5 144,-234.5 144,-209.5 27,-209.5\"/>\n<text text-anchor=\"start\" x=\"50\" y=\"-218.3\" font-family=\"Times,serif\" font-size=\"14.00\">kUnrolled</text>\n<polygon fill=\"#aed6f1\" stroke=\"transparent\" points=\"17,-184.5 17,-209.5 27,-209.5 27,-184.5 17,-184.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-184.5 17,-209.5 27,-209.5 27,-184.5 17,-184.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-184.5 27,-209.5 144,-209.5 144,-184.5 27,-184.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-184.5 27,-209.5 144,-209.5 144,-184.5 27,-184.5\"/>\n<text text-anchor=\"start\" x=\"43.5\" y=\"-193.3\" font-family=\"Times,serif\" font-size=\"14.00\">kVectorized</text>\n<polygon fill=\"#f5b7b1\" stroke=\"transparent\" points=\"17,-159.5 17,-184.5 27,-184.5 27,-159.5 17,-159.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-159.5 17,-184.5 27,-184.5 27,-159.5 17,-159.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-159.5 27,-184.5 144,-184.5 144,-159.5 27,-159.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-159.5 27,-184.5 144,-184.5 144,-159.5 27,-159.5\"/>\n<text text-anchor=\"start\" x=\"39.5\" y=\"-168.3\" font-family=\"Times,serif\" font-size=\"14.00\">kParallelized</text>\n<polygon fill=\"#a9dfbf\" stroke=\"transparent\" points=\"17,-134.5 17,-159.5 27,-159.5 27,-134.5 17,-134.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-134.5 17,-159.5 27,-159.5 27,-134.5 17,-134.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-134.5 27,-159.5 144,-159.5 144,-134.5 27,-134.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-134.5 27,-159.5 144,-159.5 144,-134.5 27,-134.5\"/>\n<text text-anchor=\"start\" x=\"42.5\" y=\"-143.3\" font-family=\"Times,serif\" font-size=\"14.00\">kTensorized</text>\n</g>\n<!-- Stage_0 -->\n<g id=\"node2\" class=\"node\">\n<title>Stage_0</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"162,-227.5 162,-267.5 224,-267.5 224,-227.5 162,-227.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"162,-227.5 162,-267.5 224,-267.5 224,-227.5 162,-227.5\"/>\n<text text-anchor=\"start\" x=\"188\" y=\"-251.3\" font-family=\"Times,serif\" font-size=\"14.00\">A</text>\n<text text-anchor=\"start\" x=\"167\" y=\"-236.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n</g>\n<!-- ROOT -->\n<g id=\"node9\" class=\"node\">\n<title>ROOT</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"706\" cy=\"-549\" rx=\"27\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"706\" y=\"-545.3\" font-family=\"Times,serif\" font-size=\"14.00\">ROOT</text>\n</g>\n<!-- Stage_0&#45;&gt;ROOT -->\n<g id=\"edge1\" class=\"edge\">\n<title>Stage_0-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M189.29,-267.67C181.51,-314.29 169.1,-434.17 233,-495 264.43,-524.92 562.68,-541.42 668.77,-546.38\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"668.85,-549.89 679,-546.85 669.17,-542.9 668.85,-549.89\"/>\n</g>\n<!-- Stage_1 -->\n<g id=\"node3\" class=\"node\">\n<title>Stage_1</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"242,-342.5 242,-382.5 478,-382.5 478,-342.5 242,-342.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"242,-342.5 242,-382.5 478,-382.5 478,-342.5 242,-342.5\"/>\n<text text-anchor=\"start\" x=\"325\" y=\"-366.3\" font-family=\"Times,serif\" font-size=\"14.00\">pad_temp</text>\n<text text-anchor=\"start\" x=\"334\" y=\"-351.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"242,-302.5 242,-342.5 279,-342.5 279,-302.5 242,-302.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"242,-302.5 242,-342.5 279,-342.5 279,-302.5 242,-302.5\"/>\n<text text-anchor=\"start\" x=\"255.5\" y=\"-318.8\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"279,-302.5 279,-342.5 478,-342.5 478,-302.5 279,-302.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"279,-302.5 279,-342.5 478,-342.5 478,-302.5 279,-302.5\"/>\n<text text-anchor=\"start\" x=\"310\" y=\"-326.3\" font-family=\"Times,serif\" font-size=\"14.00\">i0: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-311.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=34)</text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"242,-262.5 242,-302.5 279,-302.5 279,-262.5 242,-262.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"242,-262.5 242,-302.5 279,-302.5 279,-262.5 242,-262.5\"/>\n<text text-anchor=\"start\" x=\"255.5\" y=\"-278.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"279,-262.5 279,-302.5 478,-302.5 478,-262.5 279,-262.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"279,-262.5 279,-302.5 478,-302.5 478,-262.5 279,-262.5\"/>\n<text text-anchor=\"start\" x=\"310\" y=\"-286.3\" font-family=\"Times,serif\" font-size=\"14.00\">i1: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"297.5\" y=\"-271.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=34)</text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"242,-222.5 242,-262.5 279,-262.5 279,-222.5 242,-222.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"242,-222.5 242,-262.5 279,-262.5 279,-222.5 242,-222.5\"/>\n<text text-anchor=\"start\" x=\"255.5\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"279,-222.5 279,-262.5 478,-262.5 478,-222.5 279,-222.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"279,-222.5 279,-262.5 478,-262.5 478,-222.5 279,-222.5\"/>\n<text text-anchor=\"start\" x=\"310\" y=\"-246.3\" font-family=\"Times,serif\" font-size=\"14.00\">i2: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"293\" y=\"-231.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=256)</text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"242,-182.5 242,-222.5 279,-222.5 279,-182.5 242,-182.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"242,-182.5 242,-222.5 279,-222.5 279,-182.5 242,-182.5\"/>\n<text text-anchor=\"start\" x=\"255.5\" y=\"-198.8\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"279,-182.5 279,-222.5 478,-222.5 478,-182.5 279,-182.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"279,-182.5 279,-222.5 478,-222.5 478,-182.5 279,-182.5\"/>\n<text text-anchor=\"start\" x=\"310\" y=\"-206.3\" font-family=\"Times,serif\" font-size=\"14.00\">i3: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"302\" y=\"-191.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=1)</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"242,-112.5 242,-182.5 478,-182.5 478,-112.5 242,-112.5\"/>\n<text text-anchor=\"start\" x=\"261.5\" y=\"-166.3\" font-family=\"Times,serif\" font-size=\"14.00\">[tir.if_then_else(((((i0 &gt;= 1)</text>\n<text text-anchor=\"start\" x=\"247\" y=\"-151.3\" font-family=\"Times,serif\" font-size=\"14.00\"> &amp;&amp; (i0 &lt; 33)) &amp;&amp; (i1 &gt;= 1)) &amp;</text>\n<text text-anchor=\"start\" x=\"265.5\" y=\"-136.3\" font-family=\"Times,serif\" font-size=\"14.00\">&amp; (i1 &lt; 33)), A[(i0 - 1), (i1 </text>\n<text text-anchor=\"start\" x=\"306\" y=\"-121.3\" font-family=\"Times,serif\" font-size=\"14.00\">- 1), i2, i3], 0f)]</text>\n</g>\n<!-- Stage_1&#45;&gt;ROOT -->\n<g id=\"edge2\" class=\"edge\">\n<title>Stage_1-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M403.78,-382.57C423.31,-423.98 450.38,-466.21 487,-495 540.18,-536.81 621.44,-546.32 668.58,-548.09\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"668.57,-551.59 678.66,-548.37 668.76,-544.59 668.57,-551.59\"/>\n</g>\n<!-- Stage_2 -->\n<g id=\"node4\" class=\"node\">\n<title>Stage_2</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"496,-227.5 496,-267.5 558,-267.5 558,-227.5 496,-227.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"496,-227.5 496,-267.5 558,-267.5 558,-227.5 496,-227.5\"/>\n<text text-anchor=\"start\" x=\"519.5\" y=\"-251.3\" font-family=\"Times,serif\" font-size=\"14.00\">W</text>\n<text text-anchor=\"start\" x=\"501\" y=\"-236.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n</g>\n<!-- Stage_2&#45;&gt;ROOT -->\n<g id=\"edge3\" class=\"edge\">\n<title>Stage_2-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M524.31,-267.71C519.1,-312.88 512.59,-427.11 568,-495 592.86,-525.46 637.38,-538.44 669.13,-543.96\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"668.94,-547.47 679.36,-545.56 670.02,-540.56 668.94,-547.47\"/>\n</g>\n<!-- Stage_3 -->\n<g id=\"node5\" class=\"node\">\n<title>Stage_3</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"577,-454.5 577,-494.5 836,-494.5 836,-454.5 577,-454.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"577,-454.5 577,-494.5 836,-494.5 836,-454.5 577,-454.5\"/>\n<text text-anchor=\"start\" x=\"658.5\" y=\"-478.3\" font-family=\"Times,serif\" font-size=\"14.00\">conv2d_hwcn</text>\n<text text-anchor=\"start\" x=\"680.5\" y=\"-463.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"577,-414.5 577,-454.5 622,-454.5 622,-414.5 577,-414.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"577,-414.5 577,-454.5 622,-454.5 622,-414.5 577,-414.5\"/>\n<text text-anchor=\"start\" x=\"594.5\" y=\"-430.8\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"622,-414.5 622,-454.5 836,-454.5 836,-414.5 622,-414.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"622,-414.5 622,-454.5 836,-454.5 836,-414.5 622,-414.5\"/>\n<text text-anchor=\"start\" x=\"659\" y=\"-438.3\" font-family=\"Times,serif\" font-size=\"14.00\">yy: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"648\" y=\"-423.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=32)</text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"577,-374.5 577,-414.5 622,-414.5 622,-374.5 577,-374.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"577,-374.5 577,-414.5 622,-414.5 622,-374.5 577,-374.5\"/>\n<text text-anchor=\"start\" x=\"594.5\" y=\"-390.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"622,-374.5 622,-414.5 836,-414.5 836,-374.5 622,-374.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"622,-374.5 622,-414.5 836,-414.5 836,-374.5 622,-374.5\"/>\n<text text-anchor=\"start\" x=\"659\" y=\"-398.3\" font-family=\"Times,serif\" font-size=\"14.00\">xx: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"648\" y=\"-383.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=32)</text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"577,-334.5 577,-374.5 622,-374.5 622,-334.5 577,-334.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"577,-334.5 577,-374.5 622,-374.5 622,-334.5 577,-334.5\"/>\n<text text-anchor=\"start\" x=\"594.5\" y=\"-350.8\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"622,-334.5 622,-374.5 836,-374.5 836,-334.5 622,-334.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"622,-334.5 622,-374.5 836,-374.5 836,-334.5 622,-334.5\"/>\n<text text-anchor=\"start\" x=\"662.5\" y=\"-358.3\" font-family=\"Times,serif\" font-size=\"14.00\">ff: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"643.5\" y=\"-343.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=256)</text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"577,-294.5 577,-334.5 622,-334.5 622,-294.5 577,-294.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"577,-294.5 577,-334.5 622,-334.5 622,-294.5 577,-294.5\"/>\n<text text-anchor=\"start\" x=\"594.5\" y=\"-310.8\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"622,-294.5 622,-334.5 836,-334.5 836,-294.5 622,-294.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"622,-294.5 622,-334.5 836,-334.5 836,-294.5 622,-294.5\"/>\n<text text-anchor=\"start\" x=\"658\" y=\"-318.3\" font-family=\"Times,serif\" font-size=\"14.00\">nn: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"652.5\" y=\"-303.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=1)</text>\n<polygon fill=\"#fad7a0\" stroke=\"transparent\" points=\"577,-254.5 577,-294.5 622,-294.5 622,-254.5 577,-254.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"577,-254.5 577,-294.5 622,-294.5 622,-254.5 577,-254.5\"/>\n<text text-anchor=\"start\" x=\"594.5\" y=\"-270.8\" font-family=\"Times,serif\" font-size=\"14.00\">4</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"622,-254.5 622,-294.5 836,-294.5 836,-254.5 622,-254.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"622,-254.5 622,-294.5 836,-294.5 836,-254.5 622,-254.5\"/>\n<text text-anchor=\"start\" x=\"639.5\" y=\"-278.3\" font-family=\"Times,serif\" font-size=\"14.00\">rx: int32(kCommReduce)</text>\n<text text-anchor=\"start\" x=\"652.5\" y=\"-263.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=3)</text>\n<polygon fill=\"#fad7a0\" stroke=\"transparent\" points=\"577,-214.5 577,-254.5 622,-254.5 622,-214.5 577,-214.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"577,-214.5 577,-254.5 622,-254.5 622,-214.5 577,-214.5\"/>\n<text text-anchor=\"start\" x=\"594.5\" y=\"-230.8\" font-family=\"Times,serif\" font-size=\"14.00\">5</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"622,-214.5 622,-254.5 836,-254.5 836,-214.5 622,-214.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"622,-214.5 622,-254.5 836,-254.5 836,-214.5 622,-214.5\"/>\n<text text-anchor=\"start\" x=\"639.5\" y=\"-238.3\" font-family=\"Times,serif\" font-size=\"14.00\">ry: int32(kCommReduce)</text>\n<text text-anchor=\"start\" x=\"652.5\" y=\"-223.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=3)</text>\n<polygon fill=\"#fad7a0\" stroke=\"transparent\" points=\"577,-174.5 577,-214.5 622,-214.5 622,-174.5 577,-174.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"577,-174.5 577,-214.5 622,-214.5 622,-174.5 577,-174.5\"/>\n<text text-anchor=\"start\" x=\"594.5\" y=\"-190.8\" font-family=\"Times,serif\" font-size=\"14.00\">6</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"622,-174.5 622,-214.5 836,-214.5 836,-174.5 622,-174.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"622,-174.5 622,-214.5 836,-214.5 836,-174.5 622,-174.5\"/>\n<text text-anchor=\"start\" x=\"640\" y=\"-198.3\" font-family=\"Times,serif\" font-size=\"14.00\">rc: int32(kCommReduce)</text>\n<text text-anchor=\"start\" x=\"643.5\" y=\"-183.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=256)</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"577,0.5 577,-174.5 836,-174.5 836,0.5 577,0.5\"/>\n<text text-anchor=\"start\" x=\"582\" y=\"-158.3\" font-family=\"Times,serif\" font-size=\"14.00\">[reduce(combiner=comm_reducer(</text>\n<text text-anchor=\"start\" x=\"603.5\" y=\"-143.3\" font-family=\"Times,serif\" font-size=\"14.00\">result=[(x + y)], lhs=[x], rhs</text>\n<text text-anchor=\"start\" x=\"601\" y=\"-128.3\" font-family=\"Times,serif\" font-size=\"14.00\">=[y], identity_element=[0f]), </text>\n<text text-anchor=\"start\" x=\"595\" y=\"-113.3\" font-family=\"Times,serif\" font-size=\"14.00\">source=[(pad_temp[(yy + ry), (</text>\n<text text-anchor=\"start\" x=\"606.5\" y=\"-98.3\" font-family=\"Times,serif\" font-size=\"14.00\">xx + rx), rc, nn]*W[ry, rx, rc</text>\n<text text-anchor=\"start\" x=\"613.5\" y=\"-83.3\" font-family=\"Times,serif\" font-size=\"14.00\">, ff])], init=[], axis=[iter_v</text>\n<text text-anchor=\"start\" x=\"598.5\" y=\"-68.3\" font-family=\"Times,serif\" font-size=\"14.00\">ar(rx, range(min=0, ext=3)), i</text>\n<text text-anchor=\"start\" x=\"593.5\" y=\"-53.3\" font-family=\"Times,serif\" font-size=\"14.00\">ter_var(ry, range(min=0, ext=3</text>\n<text text-anchor=\"start\" x=\"602.5\" y=\"-38.3\" font-family=\"Times,serif\" font-size=\"14.00\">)), iter_var(rc, range(min=0, </text>\n<text text-anchor=\"start\" x=\"595\" y=\"-23.3\" font-family=\"Times,serif\" font-size=\"14.00\">ext=256))], where=(bool)1, val</text>\n<text text-anchor=\"start\" x=\"659\" y=\"-8.3\" font-family=\"Times,serif\" font-size=\"14.00\">ue_index=0)]</text>\n</g>\n<!-- Stage_3&#45;&gt;ROOT -->\n<g id=\"edge4\" class=\"edge\">\n<title>Stage_3-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M706,-495.14C706,-504.6 706,-513.15 706,-520.48\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"702.5,-520.64 706,-530.64 709.5,-520.64 702.5,-520.64\"/>\n</g>\n<!-- Stage_4 -->\n<g id=\"node6\" class=\"node\">\n<title>Stage_4</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"854,-227.5 854,-267.5 916,-267.5 916,-227.5 854,-227.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"854,-227.5 854,-267.5 916,-267.5 916,-227.5 854,-227.5\"/>\n<text text-anchor=\"start\" x=\"870\" y=\"-251.3\" font-family=\"Times,serif\" font-size=\"14.00\">bias</text>\n<text text-anchor=\"start\" x=\"859\" y=\"-236.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n</g>\n<!-- Stage_4&#45;&gt;ROOT -->\n<g id=\"edge5\" class=\"edge\">\n<title>Stage_4-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M887.8,-267.71C893.24,-312.88 900.32,-427.11 845,-495 819.83,-525.89 774.5,-538.8 742.46,-544.18\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"741.93,-540.72 732.57,-545.67 742.98,-547.64 741.93,-540.72\"/>\n</g>\n<!-- Stage_5 -->\n<g id=\"node7\" class=\"node\">\n<title>Stage_5</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"935,-327.5 935,-367.5 1168,-367.5 1168,-327.5 935,-327.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"935,-327.5 935,-367.5 1168,-367.5 1168,-327.5 935,-327.5\"/>\n<text text-anchor=\"start\" x=\"1030\" y=\"-351.3\" font-family=\"Times,serif\" font-size=\"14.00\">T_add</text>\n<text text-anchor=\"start\" x=\"1025.5\" y=\"-336.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"935,-287.5 935,-327.5 971,-327.5 971,-287.5 935,-287.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"935,-287.5 935,-327.5 971,-327.5 971,-287.5 935,-287.5\"/>\n<text text-anchor=\"start\" x=\"948\" y=\"-303.8\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"971,-287.5 971,-327.5 1168,-327.5 1168,-287.5 971,-287.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"971,-287.5 971,-327.5 1168,-327.5 1168,-287.5 971,-287.5\"/>\n<text text-anchor=\"start\" x=\"995\" y=\"-311.3\" font-family=\"Times,serif\" font-size=\"14.00\">ax0: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"988.5\" y=\"-296.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=32)</text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"935,-247.5 935,-287.5 971,-287.5 971,-247.5 935,-247.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"935,-247.5 935,-287.5 971,-287.5 971,-247.5 935,-247.5\"/>\n<text text-anchor=\"start\" x=\"948\" y=\"-263.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"971,-247.5 971,-287.5 1168,-287.5 1168,-247.5 971,-247.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"971,-247.5 971,-287.5 1168,-287.5 1168,-247.5 971,-247.5\"/>\n<text text-anchor=\"start\" x=\"995\" y=\"-271.3\" font-family=\"Times,serif\" font-size=\"14.00\">ax1: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"988.5\" y=\"-256.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=32)</text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"935,-207.5 935,-247.5 971,-247.5 971,-207.5 935,-207.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"935,-207.5 935,-247.5 971,-247.5 971,-207.5 935,-207.5\"/>\n<text text-anchor=\"start\" x=\"948\" y=\"-223.8\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"971,-207.5 971,-247.5 1168,-247.5 1168,-207.5 971,-207.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"971,-207.5 971,-247.5 1168,-247.5 1168,-207.5 971,-207.5\"/>\n<text text-anchor=\"start\" x=\"995\" y=\"-231.3\" font-family=\"Times,serif\" font-size=\"14.00\">ax2: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"984\" y=\"-216.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=256)</text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"935,-167.5 935,-207.5 971,-207.5 971,-167.5 935,-167.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"935,-167.5 935,-207.5 971,-207.5 971,-167.5 935,-167.5\"/>\n<text text-anchor=\"start\" x=\"948\" y=\"-183.8\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"971,-167.5 971,-207.5 1168,-207.5 1168,-167.5 971,-167.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"971,-167.5 971,-207.5 1168,-207.5 1168,-167.5 971,-167.5\"/>\n<text text-anchor=\"start\" x=\"995\" y=\"-191.3\" font-family=\"Times,serif\" font-size=\"14.00\">ax3: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"993\" y=\"-176.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=1)</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"935,-127.5 935,-167.5 1168,-167.5 1168,-127.5 935,-127.5\"/>\n<text text-anchor=\"start\" x=\"940\" y=\"-151.3\" font-family=\"Times,serif\" font-size=\"14.00\">[(conv2d_hwcn[ax0, ax1, ax2, a</text>\n<text text-anchor=\"start\" x=\"965.5\" y=\"-136.3\" font-family=\"Times,serif\" font-size=\"14.00\">x3] + bias[0, ax2, ax3])]</text>\n</g>\n<!-- Stage_5&#45;&gt;ROOT -->\n<g id=\"edge6\" class=\"edge\">\n<title>Stage_5-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M1014.49,-367.53C994.81,-413.51 965.94,-462.71 925,-495 871.75,-537 790.17,-546.42 743.06,-548.13\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"742.9,-544.63 732.99,-548.39 743.08,-551.63 742.9,-544.63\"/>\n</g>\n<!-- Stage_6 -->\n<g id=\"node8\" class=\"node\">\n<title>Stage_6</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"1186,-327.5 1186,-367.5 1394,-367.5 1394,-327.5 1186,-327.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1186,-327.5 1186,-367.5 1394,-367.5 1394,-327.5 1186,-327.5\"/>\n<text text-anchor=\"start\" x=\"1259\" y=\"-351.3\" font-family=\"Times,serif\" font-size=\"14.00\">compute</text>\n<text text-anchor=\"start\" x=\"1264\" y=\"-336.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"1186,-287.5 1186,-327.5 1209,-327.5 1209,-287.5 1186,-287.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1186,-287.5 1186,-327.5 1209,-327.5 1209,-287.5 1186,-287.5\"/>\n<text text-anchor=\"start\" x=\"1192.5\" y=\"-303.8\" font-family=\"Times,serif\" font-size=\"14.00\">0</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"1209,-287.5 1209,-327.5 1394,-327.5 1394,-287.5 1209,-287.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1209,-287.5 1209,-327.5 1394,-327.5 1394,-287.5 1209,-287.5\"/>\n<text text-anchor=\"start\" x=\"1233\" y=\"-311.3\" font-family=\"Times,serif\" font-size=\"14.00\">i0: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"1220.5\" y=\"-296.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=32)</text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"1186,-247.5 1186,-287.5 1209,-287.5 1209,-247.5 1186,-247.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1186,-247.5 1186,-287.5 1209,-287.5 1209,-247.5 1186,-247.5\"/>\n<text text-anchor=\"start\" x=\"1192.5\" y=\"-263.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"1209,-247.5 1209,-287.5 1394,-287.5 1394,-247.5 1209,-247.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1209,-247.5 1209,-287.5 1394,-287.5 1394,-247.5 1209,-247.5\"/>\n<text text-anchor=\"start\" x=\"1233\" y=\"-271.3\" font-family=\"Times,serif\" font-size=\"14.00\">i1: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"1220.5\" y=\"-256.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=32)</text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"1186,-207.5 1186,-247.5 1209,-247.5 1209,-207.5 1186,-207.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1186,-207.5 1186,-247.5 1209,-247.5 1209,-207.5 1186,-207.5\"/>\n<text text-anchor=\"start\" x=\"1192.5\" y=\"-223.8\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"1209,-207.5 1209,-247.5 1394,-247.5 1394,-207.5 1209,-207.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1209,-207.5 1209,-247.5 1394,-247.5 1394,-207.5 1209,-207.5\"/>\n<text text-anchor=\"start\" x=\"1233\" y=\"-231.3\" font-family=\"Times,serif\" font-size=\"14.00\">i2: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"1216\" y=\"-216.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=256)</text>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"1186,-167.5 1186,-207.5 1209,-207.5 1209,-167.5 1186,-167.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1186,-167.5 1186,-207.5 1209,-207.5 1209,-167.5 1186,-167.5\"/>\n<text text-anchor=\"start\" x=\"1192.5\" y=\"-183.8\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"1209,-167.5 1209,-207.5 1394,-207.5 1394,-167.5 1209,-167.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1209,-167.5 1209,-207.5 1394,-207.5 1394,-167.5 1209,-167.5\"/>\n<text text-anchor=\"start\" x=\"1233\" y=\"-191.3\" font-family=\"Times,serif\" font-size=\"14.00\">i3: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"1225\" y=\"-176.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=1)</text>\n<polygon fill=\"none\" stroke=\"black\" points=\"1186,-127.5 1186,-167.5 1394,-167.5 1394,-127.5 1186,-127.5\"/>\n<text text-anchor=\"start\" x=\"1191\" y=\"-151.3\" font-family=\"Times,serif\" font-size=\"14.00\">[max(T_add[i0, i1, i2, i3], 0f</text>\n<text text-anchor=\"start\" x=\"1284.5\" y=\"-136.3\" font-family=\"Times,serif\" font-size=\"14.00\">)]</text>\n</g>\n<!-- Stage_6&#45;&gt;ROOT -->\n<g id=\"edge7\" class=\"edge\">\n<title>Stage_6-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M1262.71,-367.63C1245.83,-414.63 1219.05,-464.57 1177,-495 1107.94,-544.98 842.12,-548.78 743.29,-548.41\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"743.19,-544.9 733.17,-548.35 743.15,-551.9 743.19,-544.9\"/>\n</g>\n</g>\n</svg>",
            "text/plain": [
              "<IPython.core.display.SVG object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "tree = tedd.viz_schedule_tree(s, show_svg=True)\n",
        "# tedd.viz_schedule_tree(s, dot_file_path=\"/tmp/scheduletree.dot\")\n",
        "display_svg(tree)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "刚刚渲染了调度树图。您可能会注意到关于范围不可用的警告。\n",
        "\n",
        "该消息还建议调用 `normalize()` 来推断范围信息。鼓励您比较 `normalize()` 前后的图表，以了解其影响。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "image/svg+xml": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"1402pt\" height=\"344pt\" viewBox=\"0.00 0.00 1402.00 344.00\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 340)\">\n<title>Schedule Tree</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-340 1398,-340 1398,4 -4,4\"/>\n<g id=\"clust1\" class=\"cluster\">\n<title>cluster_legend</title>\n<polygon fill=\"none\" stroke=\"black\" points=\"8,-8 8,-272 152,-272 152,-8 8,-8\"/>\n<text text-anchor=\"middle\" x=\"80\" y=\"-15.8\" font-family=\"Times,serif\" font-size=\"14.00\">Legend</text>\n</g>\n<!-- legend -->\n<g id=\"node1\" class=\"node\">\n<title>legend</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"17,-238.5 17,-263.5 27,-263.5 27,-238.5 17,-238.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-238.5 17,-263.5 27,-263.5 27,-238.5 17,-238.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-238.5 27,-263.5 144,-263.5 144,-238.5 27,-238.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-238.5 27,-263.5 144,-263.5 144,-238.5 27,-238.5\"/>\n<text text-anchor=\"start\" x=\"52\" y=\"-247.3\" font-family=\"Times,serif\" font-size=\"14.00\">kDataPar</text>\n<polygon fill=\"#2980b9\" stroke=\"transparent\" points=\"17,-213.5 17,-238.5 27,-238.5 27,-213.5 17,-213.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-213.5 17,-238.5 27,-238.5 27,-213.5 17,-213.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-213.5 27,-238.5 144,-238.5 144,-213.5 27,-213.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-213.5 27,-238.5 144,-238.5 144,-213.5 27,-213.5\"/>\n<text text-anchor=\"start\" x=\"36\" y=\"-222.3\" font-family=\"Times,serif\" font-size=\"14.00\">kThreadIndex</text>\n<polygon fill=\"#fad7a0\" stroke=\"transparent\" points=\"17,-188.5 17,-213.5 27,-213.5 27,-188.5 17,-188.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-188.5 17,-213.5 27,-213.5 27,-188.5 17,-188.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-188.5 27,-213.5 144,-213.5 144,-188.5 27,-188.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-188.5 27,-213.5 144,-213.5 144,-188.5 27,-188.5\"/>\n<text text-anchor=\"start\" x=\"32\" y=\"-197.3\" font-family=\"Times,serif\" font-size=\"14.00\">kCommReduce</text>\n<polygon fill=\"#d35400\" stroke=\"transparent\" points=\"17,-163.5 17,-188.5 27,-188.5 27,-163.5 17,-163.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-163.5 17,-188.5 27,-188.5 27,-163.5 17,-163.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-163.5 27,-188.5 144,-188.5 144,-163.5 27,-163.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-163.5 27,-188.5 144,-188.5 144,-163.5 27,-163.5\"/>\n<text text-anchor=\"start\" x=\"51.5\" y=\"-172.3\" font-family=\"Times,serif\" font-size=\"14.00\">kOrdered</text>\n<polygon fill=\"#abb2b9\" stroke=\"transparent\" points=\"17,-138.5 17,-163.5 27,-163.5 27,-138.5 17,-138.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-138.5 17,-163.5 27,-163.5 27,-138.5 17,-138.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-138.5 27,-163.5 144,-163.5 144,-138.5 27,-138.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-138.5 27,-163.5 144,-163.5 144,-138.5 27,-138.5\"/>\n<text text-anchor=\"start\" x=\"53.5\" y=\"-147.3\" font-family=\"Times,serif\" font-size=\"14.00\">kOpaque</text>\n<polygon fill=\"#d2b4de\" stroke=\"transparent\" points=\"17,-113.5 17,-138.5 27,-138.5 27,-113.5 17,-113.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-113.5 17,-138.5 27,-138.5 27,-113.5 17,-113.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-113.5 27,-138.5 144,-138.5 144,-113.5 27,-113.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-113.5 27,-138.5 144,-138.5 144,-113.5 27,-113.5\"/>\n<text text-anchor=\"start\" x=\"50\" y=\"-122.3\" font-family=\"Times,serif\" font-size=\"14.00\">kUnrolled</text>\n<polygon fill=\"#aed6f1\" stroke=\"transparent\" points=\"17,-88.5 17,-113.5 27,-113.5 27,-88.5 17,-88.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-88.5 17,-113.5 27,-113.5 27,-88.5 17,-88.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-88.5 27,-113.5 144,-113.5 144,-88.5 27,-88.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-88.5 27,-113.5 144,-113.5 144,-88.5 27,-88.5\"/>\n<text text-anchor=\"start\" x=\"43.5\" y=\"-97.3\" font-family=\"Times,serif\" font-size=\"14.00\">kVectorized</text>\n<polygon fill=\"#f5b7b1\" stroke=\"transparent\" points=\"17,-63.5 17,-88.5 27,-88.5 27,-63.5 17,-63.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-63.5 17,-88.5 27,-88.5 27,-63.5 17,-63.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-63.5 27,-88.5 144,-88.5 144,-63.5 27,-63.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-63.5 27,-88.5 144,-88.5 144,-63.5 27,-63.5\"/>\n<text text-anchor=\"start\" x=\"39.5\" y=\"-72.3\" font-family=\"Times,serif\" font-size=\"14.00\">kParallelized</text>\n<polygon fill=\"#a9dfbf\" stroke=\"transparent\" points=\"17,-38.5 17,-63.5 27,-63.5 27,-38.5 17,-38.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-38.5 17,-63.5 27,-63.5 27,-38.5 17,-38.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-38.5 27,-63.5 144,-63.5 144,-38.5 27,-38.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-38.5 27,-63.5 144,-63.5 144,-38.5 27,-38.5\"/>\n<text text-anchor=\"start\" x=\"42.5\" y=\"-47.3\" font-family=\"Times,serif\" font-size=\"14.00\">kTensorized</text>\n</g>\n<!-- Stage_0 -->\n<g id=\"node2\" class=\"node\">\n<title>Stage_0</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"162,-131.5 162,-171.5 224,-171.5 224,-131.5 162,-131.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"162,-131.5 162,-171.5 224,-171.5 224,-131.5 162,-131.5\"/>\n<text text-anchor=\"start\" x=\"188\" y=\"-155.3\" font-family=\"Times,serif\" font-size=\"14.00\">A</text>\n<text text-anchor=\"start\" x=\"167\" y=\"-140.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n</g>\n<!-- ROOT -->\n<g id=\"node9\" class=\"node\">\n<title>ROOT</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"706\" cy=\"-318\" rx=\"27\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"706\" y=\"-314.3\" font-family=\"Times,serif\" font-size=\"14.00\">ROOT</text>\n</g>\n<!-- Stage_0&#45;&gt;ROOT -->\n<g id=\"edge1\" class=\"edge\">\n<title>Stage_0-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M193.36,-171.82C195,-198.92 202.34,-247.64 233,-272 266.88,-298.91 562.89,-311.94 668.65,-315.76\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"668.73,-319.27 678.85,-316.12 668.98,-312.27 668.73,-319.27\"/>\n</g>\n<!-- Stage_1 -->\n<g id=\"node3\" class=\"node\">\n<title>Stage_1</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"242,-166.5 242,-206.5 478,-206.5 478,-166.5 242,-166.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"242,-166.5 242,-206.5 478,-206.5 478,-166.5 242,-166.5\"/>\n<text text-anchor=\"start\" x=\"325\" y=\"-190.3\" font-family=\"Times,serif\" font-size=\"14.00\">pad_temp</text>\n<text text-anchor=\"start\" x=\"334\" y=\"-175.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"none\" stroke=\"black\" points=\"242,-96.5 242,-166.5 478,-166.5 478,-96.5 242,-96.5\"/>\n<text text-anchor=\"start\" x=\"261.5\" y=\"-150.3\" font-family=\"Times,serif\" font-size=\"14.00\">[tir.if_then_else(((((i0 &gt;= 1)</text>\n<text text-anchor=\"start\" x=\"247\" y=\"-135.3\" font-family=\"Times,serif\" font-size=\"14.00\"> &amp;&amp; (i0 &lt; 33)) &amp;&amp; (i1 &gt;= 1)) &amp;</text>\n<text text-anchor=\"start\" x=\"265.5\" y=\"-120.3\" font-family=\"Times,serif\" font-size=\"14.00\">&amp; (i1 &lt; 33)), A[(i0 - 1), (i1 </text>\n<text text-anchor=\"start\" x=\"306\" y=\"-105.3\" font-family=\"Times,serif\" font-size=\"14.00\">- 1), i2, i3], 0f)]</text>\n</g>\n<!-- Stage_1&#45;&gt;ROOT -->\n<g id=\"edge2\" class=\"edge\">\n<title>Stage_1-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M405.02,-206.72C427.33,-230.22 456.1,-255.96 487,-272 545.68,-302.46 623.24,-312.31 668.56,-315.49\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"668.62,-319 678.82,-316.13 669.06,-312.01 668.62,-319\"/>\n</g>\n<!-- Stage_2 -->\n<g id=\"node4\" class=\"node\">\n<title>Stage_2</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"496,-131.5 496,-171.5 558,-171.5 558,-131.5 496,-131.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"496,-131.5 496,-171.5 558,-171.5 558,-131.5 496,-131.5\"/>\n<text text-anchor=\"start\" x=\"519.5\" y=\"-155.3\" font-family=\"Times,serif\" font-size=\"14.00\">W</text>\n<text text-anchor=\"start\" x=\"501\" y=\"-140.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n</g>\n<!-- Stage_2&#45;&gt;ROOT -->\n<g id=\"edge3\" class=\"edge\">\n<title>Stage_2-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M528.4,-171.83C531.33,-198.06 540.34,-244.76 568,-272 595.18,-298.77 638.47,-309.61 669.32,-314.01\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"668.9,-317.48 679.26,-315.26 669.78,-310.54 668.9,-317.48\"/>\n</g>\n<!-- Stage_3 -->\n<g id=\"node5\" class=\"node\">\n<title>Stage_3</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"577,-218.5 577,-258.5 836,-258.5 836,-218.5 577,-218.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"577,-218.5 577,-258.5 836,-258.5 836,-218.5 577,-218.5\"/>\n<text text-anchor=\"start\" x=\"658.5\" y=\"-242.3\" font-family=\"Times,serif\" font-size=\"14.00\">conv2d_hwcn</text>\n<text text-anchor=\"start\" x=\"680.5\" y=\"-227.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"none\" stroke=\"black\" points=\"577,-43.5 577,-218.5 836,-218.5 836,-43.5 577,-43.5\"/>\n<text text-anchor=\"start\" x=\"582\" y=\"-202.3\" font-family=\"Times,serif\" font-size=\"14.00\">[reduce(combiner=comm_reducer(</text>\n<text text-anchor=\"start\" x=\"603.5\" y=\"-187.3\" font-family=\"Times,serif\" font-size=\"14.00\">result=[(x + y)], lhs=[x], rhs</text>\n<text text-anchor=\"start\" x=\"601\" y=\"-172.3\" font-family=\"Times,serif\" font-size=\"14.00\">=[y], identity_element=[0f]), </text>\n<text text-anchor=\"start\" x=\"595\" y=\"-157.3\" font-family=\"Times,serif\" font-size=\"14.00\">source=[(pad_temp[(yy + ry), (</text>\n<text text-anchor=\"start\" x=\"606.5\" y=\"-142.3\" font-family=\"Times,serif\" font-size=\"14.00\">xx + rx), rc, nn]*W[ry, rx, rc</text>\n<text text-anchor=\"start\" x=\"613.5\" y=\"-127.3\" font-family=\"Times,serif\" font-size=\"14.00\">, ff])], init=[], axis=[iter_v</text>\n<text text-anchor=\"start\" x=\"598.5\" y=\"-112.3\" font-family=\"Times,serif\" font-size=\"14.00\">ar(rx, range(min=0, ext=3)), i</text>\n<text text-anchor=\"start\" x=\"593.5\" y=\"-97.3\" font-family=\"Times,serif\" font-size=\"14.00\">ter_var(ry, range(min=0, ext=3</text>\n<text text-anchor=\"start\" x=\"602.5\" y=\"-82.3\" font-family=\"Times,serif\" font-size=\"14.00\">)), iter_var(rc, range(min=0, </text>\n<text text-anchor=\"start\" x=\"595\" y=\"-67.3\" font-family=\"Times,serif\" font-size=\"14.00\">ext=256))], where=(bool)1, val</text>\n<text text-anchor=\"start\" x=\"659\" y=\"-52.3\" font-family=\"Times,serif\" font-size=\"14.00\">ue_index=0)]</text>\n</g>\n<!-- Stage_3&#45;&gt;ROOT -->\n<g id=\"edge4\" class=\"edge\">\n<title>Stage_3-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M706,-259C706,-270.25 706,-280.82 706,-289.79\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"702.5,-289.86 706,-299.86 709.5,-289.86 702.5,-289.86\"/>\n</g>\n<!-- Stage_4 -->\n<g id=\"node6\" class=\"node\">\n<title>Stage_4</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"854,-131.5 854,-171.5 916,-171.5 916,-131.5 854,-131.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"854,-131.5 854,-171.5 916,-171.5 916,-131.5 854,-131.5\"/>\n<text text-anchor=\"start\" x=\"870\" y=\"-155.3\" font-family=\"Times,serif\" font-size=\"14.00\">bias</text>\n<text text-anchor=\"start\" x=\"859\" y=\"-140.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n</g>\n<!-- Stage_4&#45;&gt;ROOT -->\n<g id=\"edge5\" class=\"edge\">\n<title>Stage_4-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M883.78,-171.83C881.11,-198.06 872.52,-244.75 845,-272 817.71,-299.02 774.09,-309.82 742.99,-314.13\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"742.47,-310.67 732.97,-315.36 743.32,-317.62 742.47,-310.67\"/>\n</g>\n<!-- Stage_5 -->\n<g id=\"node7\" class=\"node\">\n<title>Stage_5</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"935,-151.5 935,-191.5 1168,-191.5 1168,-151.5 935,-151.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"935,-151.5 935,-191.5 1168,-191.5 1168,-151.5 935,-151.5\"/>\n<text text-anchor=\"start\" x=\"1030\" y=\"-175.3\" font-family=\"Times,serif\" font-size=\"14.00\">T_add</text>\n<text text-anchor=\"start\" x=\"1025.5\" y=\"-160.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"none\" stroke=\"black\" points=\"935,-111.5 935,-151.5 1168,-151.5 1168,-111.5 935,-111.5\"/>\n<text text-anchor=\"start\" x=\"940\" y=\"-135.3\" font-family=\"Times,serif\" font-size=\"14.00\">[(conv2d_hwcn[ax0, ax1, ax2, a</text>\n<text text-anchor=\"start\" x=\"965.5\" y=\"-120.3\" font-family=\"Times,serif\" font-size=\"14.00\">x3] + bias[0, ax2, ax3])]</text>\n</g>\n<!-- Stage_5&#45;&gt;ROOT -->\n<g id=\"edge6\" class=\"edge\">\n<title>Stage_5-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M1020.13,-191.56C996.84,-218.33 962.56,-252.41 925,-272 866.38,-302.58 788.8,-312.39 743.46,-315.53\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"742.96,-312.05 733.2,-316.16 743.4,-319.04 742.96,-312.05\"/>\n</g>\n<!-- Stage_6 -->\n<g id=\"node8\" class=\"node\">\n<title>Stage_6</title>\n<polygon fill=\"lightgrey\" stroke=\"transparent\" points=\"1186,-151.5 1186,-191.5 1394,-191.5 1394,-151.5 1186,-151.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1186,-151.5 1186,-191.5 1394,-191.5 1394,-151.5 1186,-151.5\"/>\n<text text-anchor=\"start\" x=\"1259\" y=\"-175.3\" font-family=\"Times,serif\" font-size=\"14.00\">compute</text>\n<text text-anchor=\"start\" x=\"1264\" y=\"-160.3\" font-family=\"Times,serif\" font-size=\"14.00\">Scope: </text>\n<polygon fill=\"none\" stroke=\"black\" points=\"1186,-111.5 1186,-151.5 1394,-151.5 1394,-111.5 1186,-111.5\"/>\n<text text-anchor=\"start\" x=\"1191\" y=\"-135.3\" font-family=\"Times,serif\" font-size=\"14.00\">[max(T_add[i0, i1, i2, i3], 0f</text>\n<text text-anchor=\"start\" x=\"1284.5\" y=\"-120.3\" font-family=\"Times,serif\" font-size=\"14.00\">)]</text>\n</g>\n<!-- Stage_6&#45;&gt;ROOT -->\n<g id=\"edge7\" class=\"edge\">\n<title>Stage_6-&gt;ROOT</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M1264.62,-191.61C1244.43,-219.14 1213.56,-254.14 1177,-272 1100.79,-309.22 841.04,-315.67 743.46,-316.78\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"743.15,-313.28 733.19,-316.88 743.22,-320.28 743.15,-313.28\"/>\n</g>\n</g>\n</svg>",
            "text/plain": [
              "<IPython.core.display.SVG object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "s = s.normalize()\n",
        "# tedd.viz_schedule_tree(s, dot_file_path=\"/tmp/scheduletree2.dot\")\n",
        "tree = tedd.viz_schedule_tree(s, show_svg = True)\n",
        "display_svg(tree)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "现在，仔细看看第二个调度树。ROOT 下的每个块代表一个阶段。阶段名称显示在顶部行，计算显示在底部行。中间的行是 IterVars，外部越高，内部越低。\n",
        "\n",
        "IterVar 行包含它的索引、名称、类型和其他可选信息。以 W.shared 为例。第一行告诉它的名称 \"W.shared\" 和内存作用域 \"Shared\"。它的计算是: `W(ax0, ax1, ax2, ax3)`。它最外层的循环 IterVar 是 ax0.ax1.fused.ax2.fused.ax3.fused.outer，kDataPar 的索引为 0，绑定到 threadIdx.y 和 range(min=0, ext=8)。\n",
        "\n",
        "您还可以使用图例中所示的索引框颜色来告诉 IterVar 类型。\n",
        "\n",
        "如果一个阶段没有 compute_at 的任何其他阶段，它就有一条直接到 ROOT 节点的边。否则，它有一条边指向它所附加的 IterVar，例如 W.shared  附加到 rx.outer 中间计算阶段。\n",
        "\n",
        "```{note}\n",
        ":class: alert alert-info\n",
        "\n",
        "根据定义，itervar 是内部节点，计算是调度树的叶子节点。省略了 IterVars 之间的边和阶段内的计算，使每个阶段成为块，以提高可读性。\n",
        "```"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "image/svg+xml": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.43.0 (0)\n -->\n<!-- Title: IterVar Relationship Graph Pages: 1 -->\n<svg width=\"4860pt\" height=\"288pt\"\n viewBox=\"0.00 0.00 4860.00 288.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 284)\">\n<title>IterVar Relationship Graph</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-284 4856,-284 4856,4 -4,4\"/>\n<g id=\"clust1\" class=\"cluster\">\n<title>cluster_legend</title>\n<polygon fill=\"none\" stroke=\"black\" points=\"8,-8 8,-272 152,-272 152,-8 8,-8\"/>\n<text text-anchor=\"middle\" x=\"80\" y=\"-256.8\" font-family=\"Times,serif\" font-size=\"14.00\">Legend</text>\n</g>\n<g id=\"clust2\" class=\"cluster\">\n<title>cluster_Stage_0</title>\n<polygon fill=\"none\" stroke=\"black\" points=\"160,-102.5 160,-177.5 326,-177.5 326,-102.5 160,-102.5\"/>\n<text text-anchor=\"middle\" x=\"243\" y=\"-162.3\" font-family=\"Times,serif\" font-size=\"14.00\">A</text>\n</g>\n<g id=\"clust3\" class=\"cluster\">\n<title>cluster_Stage_1</title>\n<polygon fill=\"none\" stroke=\"black\" points=\"334,-100.5 334,-179.5 1187,-179.5 1187,-100.5 334,-100.5\"/>\n<text text-anchor=\"middle\" x=\"760.5\" y=\"-164.3\" font-family=\"Times,serif\" font-size=\"14.00\">pad_temp</text>\n</g>\n<g id=\"clust4\" class=\"cluster\">\n<title>cluster_Stage_2</title>\n<polygon fill=\"none\" stroke=\"black\" points=\"1195,-102.5 1195,-177.5 1369,-177.5 1369,-102.5 1195,-102.5\"/>\n<text text-anchor=\"middle\" x=\"1282\" y=\"-162.3\" font-family=\"Times,serif\" font-size=\"14.00\">W</text>\n</g>\n<g id=\"clust5\" class=\"cluster\">\n<title>cluster_Stage_3</title>\n<polygon fill=\"none\" stroke=\"black\" points=\"1377,-100.5 1377,-179.5 2922,-179.5 2922,-100.5 1377,-100.5\"/>\n<text text-anchor=\"middle\" x=\"2149.5\" y=\"-164.3\" font-family=\"Times,serif\" font-size=\"14.00\">conv2d_hwcn</text>\n</g>\n<g id=\"clust6\" class=\"cluster\">\n<title>cluster_Stage_4</title>\n<polygon fill=\"none\" stroke=\"black\" points=\"2930,-102.5 2930,-177.5 3122,-177.5 3122,-102.5 2930,-102.5\"/>\n<text text-anchor=\"middle\" x=\"3026\" y=\"-162.3\" font-family=\"Times,serif\" font-size=\"14.00\">bias</text>\n</g>\n<g id=\"clust7\" class=\"cluster\">\n<title>cluster_Stage_5</title>\n<polygon fill=\"none\" stroke=\"black\" points=\"3130,-100.5 3130,-179.5 3983,-179.5 3983,-100.5 3130,-100.5\"/>\n<text text-anchor=\"middle\" x=\"3556.5\" y=\"-164.3\" font-family=\"Times,serif\" font-size=\"14.00\">T_add</text>\n</g>\n<g id=\"clust8\" class=\"cluster\">\n<title>cluster_Stage_6</title>\n<polygon fill=\"none\" stroke=\"black\" points=\"3991,-100.5 3991,-179.5 4844,-179.5 4844,-100.5 3991,-100.5\"/>\n<text text-anchor=\"middle\" x=\"4417.5\" y=\"-164.3\" font-family=\"Times,serif\" font-size=\"14.00\">compute</text>\n</g>\n<!-- legend -->\n<g id=\"node1\" class=\"node\">\n<title>legend</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"17,-215.5 17,-240.5 27,-240.5 27,-215.5 17,-215.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-215.5 17,-240.5 27,-240.5 27,-215.5 17,-215.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-215.5 27,-240.5 144,-240.5 144,-215.5 27,-215.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-215.5 27,-240.5 144,-240.5 144,-215.5 27,-215.5\"/>\n<text text-anchor=\"start\" x=\"52\" y=\"-224.3\" font-family=\"Times,serif\" font-size=\"14.00\">kDataPar</text>\n<polygon fill=\"#2980b9\" stroke=\"transparent\" points=\"17,-190.5 17,-215.5 27,-215.5 27,-190.5 17,-190.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-190.5 17,-215.5 27,-215.5 27,-190.5 17,-190.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-190.5 27,-215.5 144,-215.5 144,-190.5 27,-190.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-190.5 27,-215.5 144,-215.5 144,-190.5 27,-190.5\"/>\n<text text-anchor=\"start\" x=\"36\" y=\"-199.3\" font-family=\"Times,serif\" font-size=\"14.00\">kThreadIndex</text>\n<polygon fill=\"#fad7a0\" stroke=\"transparent\" points=\"17,-165.5 17,-190.5 27,-190.5 27,-165.5 17,-165.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-165.5 17,-190.5 27,-190.5 27,-165.5 17,-165.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-165.5 27,-190.5 144,-190.5 144,-165.5 27,-165.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-165.5 27,-190.5 144,-190.5 144,-165.5 27,-165.5\"/>\n<text text-anchor=\"start\" x=\"32\" y=\"-174.3\" font-family=\"Times,serif\" font-size=\"14.00\">kCommReduce</text>\n<polygon fill=\"#d35400\" stroke=\"transparent\" points=\"17,-140.5 17,-165.5 27,-165.5 27,-140.5 17,-140.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-140.5 17,-165.5 27,-165.5 27,-140.5 17,-140.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-140.5 27,-165.5 144,-165.5 144,-140.5 27,-140.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-140.5 27,-165.5 144,-165.5 144,-140.5 27,-140.5\"/>\n<text text-anchor=\"start\" x=\"51.5\" y=\"-149.3\" font-family=\"Times,serif\" font-size=\"14.00\">kOrdered</text>\n<polygon fill=\"#abb2b9\" stroke=\"transparent\" points=\"17,-115.5 17,-140.5 27,-140.5 27,-115.5 17,-115.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-115.5 17,-140.5 27,-140.5 27,-115.5 17,-115.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-115.5 27,-140.5 144,-140.5 144,-115.5 27,-115.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-115.5 27,-140.5 144,-140.5 144,-115.5 27,-115.5\"/>\n<text text-anchor=\"start\" x=\"53.5\" y=\"-124.3\" font-family=\"Times,serif\" font-size=\"14.00\">kOpaque</text>\n<polygon fill=\"#d2b4de\" stroke=\"transparent\" points=\"17,-90.5 17,-115.5 27,-115.5 27,-90.5 17,-90.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-90.5 17,-115.5 27,-115.5 27,-90.5 17,-90.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-90.5 27,-115.5 144,-115.5 144,-90.5 27,-90.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-90.5 27,-115.5 144,-115.5 144,-90.5 27,-90.5\"/>\n<text text-anchor=\"start\" x=\"50\" y=\"-99.3\" font-family=\"Times,serif\" font-size=\"14.00\">kUnrolled</text>\n<polygon fill=\"#aed6f1\" stroke=\"transparent\" points=\"17,-65.5 17,-90.5 27,-90.5 27,-65.5 17,-65.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-65.5 17,-90.5 27,-90.5 27,-65.5 17,-65.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-65.5 27,-90.5 144,-90.5 144,-65.5 27,-65.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-65.5 27,-90.5 144,-90.5 144,-65.5 27,-65.5\"/>\n<text text-anchor=\"start\" x=\"43.5\" y=\"-74.3\" font-family=\"Times,serif\" font-size=\"14.00\">kVectorized</text>\n<polygon fill=\"#f5b7b1\" stroke=\"transparent\" points=\"17,-40.5 17,-65.5 27,-65.5 27,-40.5 17,-40.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-40.5 17,-65.5 27,-65.5 27,-40.5 17,-40.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-40.5 27,-65.5 144,-65.5 144,-40.5 27,-40.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-40.5 27,-65.5 144,-65.5 144,-40.5 27,-40.5\"/>\n<text text-anchor=\"start\" x=\"39.5\" y=\"-49.3\" font-family=\"Times,serif\" font-size=\"14.00\">kParallelized</text>\n<polygon fill=\"#a9dfbf\" stroke=\"transparent\" points=\"17,-15.5 17,-40.5 27,-40.5 27,-15.5 17,-15.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"17,-15.5 17,-40.5 27,-40.5 27,-15.5 17,-15.5\"/>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"27,-15.5 27,-40.5 144,-40.5 144,-15.5 27,-15.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"27,-15.5 27,-40.5 144,-40.5 144,-15.5 27,-15.5\"/>\n<text text-anchor=\"start\" x=\"42.5\" y=\"-24.3\" font-family=\"Times,serif\" font-size=\"14.00\">kTensorized</text>\n</g>\n<!-- A_placeholder -->\n<!-- IterVar_1_0 -->\n<g id=\"node3\" class=\"node\">\n<title>IterVar_1_0</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"983,-108.5 983,-148.5 1007,-148.5 1007,-108.5 983,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"983,-108.5 983,-148.5 1007,-148.5 1007,-108.5 983,-108.5\"/>\n<text text-anchor=\"start\" x=\"988\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"1007,-108.5 1007,-148.5 1179,-148.5 1179,-108.5 1007,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1007,-108.5 1007,-148.5 1179,-148.5 1179,-108.5 1007,-108.5\"/>\n<text text-anchor=\"start\" x=\"1024.5\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">i0: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"1012\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=34)</text>\n</g>\n<!-- IterVar_1_1 -->\n<g id=\"node4\" class=\"node\">\n<title>IterVar_1_1</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"769,-108.5 769,-148.5 793,-148.5 793,-108.5 769,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"769,-108.5 769,-148.5 793,-148.5 793,-108.5 769,-108.5\"/>\n<text text-anchor=\"start\" x=\"774\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"793,-108.5 793,-148.5 965,-148.5 965,-108.5 793,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"793,-108.5 793,-148.5 965,-148.5 965,-108.5 793,-108.5\"/>\n<text text-anchor=\"start\" x=\"810.5\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">i1: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"798\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=34)</text>\n</g>\n<!-- IterVar_1_2 -->\n<g id=\"node5\" class=\"node\">\n<title>IterVar_1_2</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"547,-108.5 547,-148.5 571,-148.5 571,-108.5 547,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"547,-108.5 547,-148.5 571,-148.5 571,-108.5 547,-108.5\"/>\n<text text-anchor=\"start\" x=\"552\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"571,-108.5 571,-148.5 752,-148.5 752,-108.5 571,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"571,-108.5 571,-148.5 752,-148.5 752,-108.5 571,-108.5\"/>\n<text text-anchor=\"start\" x=\"593\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">i2: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"576\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=256)</text>\n</g>\n<!-- IterVar_1_3 -->\n<g id=\"node6\" class=\"node\">\n<title>IterVar_1_3</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"342,-108.5 342,-148.5 366,-148.5 366,-108.5 342,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"342,-108.5 342,-148.5 366,-148.5 366,-108.5 342,-108.5\"/>\n<text text-anchor=\"start\" x=\"347\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"366,-108.5 366,-148.5 529,-148.5 529,-108.5 366,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"366,-108.5 366,-148.5 529,-148.5 529,-108.5 366,-108.5\"/>\n<text text-anchor=\"start\" x=\"379\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">i3: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"371\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=1)</text>\n</g>\n<!-- W_placeholder -->\n<!-- IterVar_3_0 -->\n<g id=\"node8\" class=\"node\">\n<title>IterVar_3_0</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"2718,-108.5 2718,-148.5 2742,-148.5 2742,-108.5 2718,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"2718,-108.5 2718,-148.5 2742,-148.5 2742,-108.5 2718,-108.5\"/>\n<text text-anchor=\"start\" x=\"2723\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"2742,-108.5 2742,-148.5 2914,-148.5 2914,-108.5 2742,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"2742,-108.5 2742,-148.5 2914,-148.5 2914,-108.5 2742,-108.5\"/>\n<text text-anchor=\"start\" x=\"2758\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">yy: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"2747\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=32)</text>\n</g>\n<!-- IterVar_3_1 -->\n<g id=\"node9\" class=\"node\">\n<title>IterVar_3_1</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"2504,-108.5 2504,-148.5 2528,-148.5 2528,-108.5 2504,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"2504,-108.5 2504,-148.5 2528,-148.5 2528,-108.5 2504,-108.5\"/>\n<text text-anchor=\"start\" x=\"2509\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"2528,-108.5 2528,-148.5 2700,-148.5 2700,-108.5 2528,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"2528,-108.5 2528,-148.5 2700,-148.5 2700,-108.5 2528,-108.5\"/>\n<text text-anchor=\"start\" x=\"2544\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">xx: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"2533\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=32)</text>\n</g>\n<!-- IterVar_3_2 -->\n<g id=\"node10\" class=\"node\">\n<title>IterVar_3_2</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"2282,-108.5 2282,-148.5 2306,-148.5 2306,-108.5 2282,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"2282,-108.5 2282,-148.5 2306,-148.5 2306,-108.5 2282,-108.5\"/>\n<text text-anchor=\"start\" x=\"2287\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"2306,-108.5 2306,-148.5 2487,-148.5 2487,-108.5 2306,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"2306,-108.5 2306,-148.5 2487,-148.5 2487,-108.5 2306,-108.5\"/>\n<text text-anchor=\"start\" x=\"2330\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">ff: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"2311\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=256)</text>\n</g>\n<!-- IterVar_3_3 -->\n<g id=\"node11\" class=\"node\">\n<title>IterVar_3_3</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"2077,-108.5 2077,-148.5 2101,-148.5 2101,-108.5 2077,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"2077,-108.5 2077,-148.5 2101,-148.5 2101,-108.5 2077,-108.5\"/>\n<text text-anchor=\"start\" x=\"2082\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"2101,-108.5 2101,-148.5 2264,-148.5 2264,-108.5 2101,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"2101,-108.5 2101,-148.5 2264,-148.5 2264,-108.5 2101,-108.5\"/>\n<text text-anchor=\"start\" x=\"2111.5\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">nn: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"2106\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=1)</text>\n</g>\n<!-- IterVar_3_4 -->\n<g id=\"node12\" class=\"node\">\n<title>IterVar_3_4</title>\n<polygon fill=\"#fad7a0\" stroke=\"transparent\" points=\"1846,-108.5 1846,-148.5 1870,-148.5 1870,-108.5 1846,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1846,-108.5 1846,-148.5 1870,-148.5 1870,-108.5 1846,-108.5\"/>\n<text text-anchor=\"start\" x=\"1851\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"1870,-108.5 1870,-148.5 2059,-148.5 2059,-108.5 1870,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1870,-108.5 1870,-148.5 2059,-148.5 2059,-108.5 1870,-108.5\"/>\n<text text-anchor=\"start\" x=\"1875\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">rx: int32(kCommReduce)</text>\n<text text-anchor=\"start\" x=\"1888\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=3)</text>\n</g>\n<!-- IterVar_3_5 -->\n<g id=\"node13\" class=\"node\">\n<title>IterVar_3_5</title>\n<polygon fill=\"#fad7a0\" stroke=\"transparent\" points=\"1615,-108.5 1615,-148.5 1639,-148.5 1639,-108.5 1615,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1615,-108.5 1615,-148.5 1639,-148.5 1639,-108.5 1615,-108.5\"/>\n<text text-anchor=\"start\" x=\"1620\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"1639,-108.5 1639,-148.5 1828,-148.5 1828,-108.5 1639,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1639,-108.5 1639,-148.5 1828,-148.5 1828,-108.5 1639,-108.5\"/>\n<text text-anchor=\"start\" x=\"1644\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">ry: int32(kCommReduce)</text>\n<text text-anchor=\"start\" x=\"1657\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=3)</text>\n</g>\n<!-- IterVar_3_6 -->\n<g id=\"node14\" class=\"node\">\n<title>IterVar_3_6</title>\n<polygon fill=\"#fad7a0\" stroke=\"transparent\" points=\"1385,-108.5 1385,-148.5 1409,-148.5 1409,-108.5 1385,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1385,-108.5 1385,-148.5 1409,-148.5 1409,-108.5 1385,-108.5\"/>\n<text text-anchor=\"start\" x=\"1390\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"1409,-108.5 1409,-148.5 1597,-148.5 1597,-108.5 1409,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"1409,-108.5 1409,-148.5 1597,-148.5 1597,-108.5 1409,-108.5\"/>\n<text text-anchor=\"start\" x=\"1414\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">rc: int32(kCommReduce)</text>\n<text text-anchor=\"start\" x=\"1417.5\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=256)</text>\n</g>\n<!-- bias_placeholder -->\n<!-- IterVar_5_0 -->\n<g id=\"node16\" class=\"node\">\n<title>IterVar_5_0</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"3779,-108.5 3779,-148.5 3803,-148.5 3803,-108.5 3779,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"3779,-108.5 3779,-148.5 3803,-148.5 3803,-108.5 3779,-108.5\"/>\n<text text-anchor=\"start\" x=\"3784\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"3803,-108.5 3803,-148.5 3975,-148.5 3975,-108.5 3803,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"3803,-108.5 3803,-148.5 3975,-148.5 3975,-108.5 3803,-108.5\"/>\n<text text-anchor=\"start\" x=\"3814.5\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">ax0: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"3808\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=32)</text>\n</g>\n<!-- IterVar_5_1 -->\n<g id=\"node17\" class=\"node\">\n<title>IterVar_5_1</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"3565,-108.5 3565,-148.5 3589,-148.5 3589,-108.5 3565,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"3565,-108.5 3565,-148.5 3589,-148.5 3589,-108.5 3565,-108.5\"/>\n<text text-anchor=\"start\" x=\"3570\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"3589,-108.5 3589,-148.5 3761,-148.5 3761,-108.5 3589,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"3589,-108.5 3589,-148.5 3761,-148.5 3761,-108.5 3589,-108.5\"/>\n<text text-anchor=\"start\" x=\"3600.5\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">ax1: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"3594\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=32)</text>\n</g>\n<!-- IterVar_5_2 -->\n<g id=\"node18\" class=\"node\">\n<title>IterVar_5_2</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"3343,-108.5 3343,-148.5 3367,-148.5 3367,-108.5 3343,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"3343,-108.5 3343,-148.5 3367,-148.5 3367,-108.5 3343,-108.5\"/>\n<text text-anchor=\"start\" x=\"3348\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"3367,-108.5 3367,-148.5 3548,-148.5 3548,-108.5 3367,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"3367,-108.5 3367,-148.5 3548,-148.5 3548,-108.5 3367,-108.5\"/>\n<text text-anchor=\"start\" x=\"3383\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">ax2: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"3372\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=256)</text>\n</g>\n<!-- IterVar_5_3 -->\n<g id=\"node19\" class=\"node\">\n<title>IterVar_5_3</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"3138,-108.5 3138,-148.5 3162,-148.5 3162,-108.5 3138,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"3138,-108.5 3138,-148.5 3162,-148.5 3162,-108.5 3138,-108.5\"/>\n<text text-anchor=\"start\" x=\"3143\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"3162,-108.5 3162,-148.5 3325,-148.5 3325,-108.5 3162,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"3162,-108.5 3162,-148.5 3325,-148.5 3325,-108.5 3162,-108.5\"/>\n<text text-anchor=\"start\" x=\"3169\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">ax3: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"3167\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=1)</text>\n</g>\n<!-- IterVar_6_0 -->\n<g id=\"node20\" class=\"node\">\n<title>IterVar_6_0</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"4640,-108.5 4640,-148.5 4664,-148.5 4664,-108.5 4640,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"4640,-108.5 4640,-148.5 4664,-148.5 4664,-108.5 4640,-108.5\"/>\n<text text-anchor=\"start\" x=\"4645\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"4664,-108.5 4664,-148.5 4836,-148.5 4836,-108.5 4664,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"4664,-108.5 4664,-148.5 4836,-148.5 4836,-108.5 4664,-108.5\"/>\n<text text-anchor=\"start\" x=\"4681.5\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">i0: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"4669\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=32)</text>\n</g>\n<!-- IterVar_6_1 -->\n<g id=\"node21\" class=\"node\">\n<title>IterVar_6_1</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"4426,-108.5 4426,-148.5 4450,-148.5 4450,-108.5 4426,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"4426,-108.5 4426,-148.5 4450,-148.5 4450,-108.5 4426,-108.5\"/>\n<text text-anchor=\"start\" x=\"4431\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"4450,-108.5 4450,-148.5 4622,-148.5 4622,-108.5 4450,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"4450,-108.5 4450,-148.5 4622,-148.5 4622,-108.5 4450,-108.5\"/>\n<text text-anchor=\"start\" x=\"4467.5\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">i1: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"4455\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=32)</text>\n</g>\n<!-- IterVar_6_2 -->\n<g id=\"node22\" class=\"node\">\n<title>IterVar_6_2</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"4204,-108.5 4204,-148.5 4228,-148.5 4228,-108.5 4204,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"4204,-108.5 4204,-148.5 4228,-148.5 4228,-108.5 4204,-108.5\"/>\n<text text-anchor=\"start\" x=\"4209\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"4228,-108.5 4228,-148.5 4409,-148.5 4409,-108.5 4228,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"4228,-108.5 4228,-148.5 4409,-148.5 4409,-108.5 4228,-108.5\"/>\n<text text-anchor=\"start\" x=\"4250\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">i2: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"4233\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=256)</text>\n</g>\n<!-- IterVar_6_3 -->\n<g id=\"node23\" class=\"node\">\n<title>IterVar_6_3</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"3999,-108.5 3999,-148.5 4023,-148.5 4023,-108.5 3999,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"3999,-108.5 3999,-148.5 4023,-148.5 4023,-108.5 3999,-108.5\"/>\n<text text-anchor=\"start\" x=\"4004\" y=\"-124.8\" font-family=\"Times,serif\" font-size=\"14.00\">&#45;1</text>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"4023,-108.5 4023,-148.5 4186,-148.5 4186,-108.5 4023,-108.5\"/>\n<polygon fill=\"none\" stroke=\"black\" points=\"4023,-108.5 4023,-148.5 4186,-148.5 4186,-108.5 4023,-108.5\"/>\n<text text-anchor=\"start\" x=\"4036\" y=\"-132.3\" font-family=\"Times,serif\" font-size=\"14.00\">i3: int32(kDataPar)</text>\n<text text-anchor=\"start\" x=\"4028\" y=\"-117.3\" font-family=\"Times,serif\" font-size=\"14.00\">range(min=0, ext=1)</text>\n</g>\n</g>\n</svg>\n"
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "from graphviz import Source\n",
        "# tedd.viz_itervar_relationship_graph(s, dot_file_path=\"/tmp/itervar.dot\")\n",
        "dot_string = tedd.viz_itervar_relationship_graph(s, output_dot_string=True)\n",
        "src = Source(dot_string)\n",
        "display_svg(src)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "最后一个是迭代关系图(IterVar Relationship Graph)。每个子图表示一个阶段，并包含 IterVar 节点和变换节点。例如，W.shared 有三个 split 节点和三个 fuse 节点。其余的是 IterVar 节点，其格式与 Schedule Trees 中的 IterVar 行相同。Root itervar 是那些不受任何变换节点驱动的迭代器，例如 ax0; 叶 IterVars 不驱动任何变换节点，并且具有非负索引，如 ax0.ax1.fused.ax2.fused.ax3.fused.outer 索引为 0。"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 小结\n",
        "\n",
        "本教程演示了 TEDD 的用法。使用一个用 TOPI 构建的示例来显示底层的调度。您还可以在任何调度原语之前和之后使用它来检查其效果。"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3.10.4 ('mxnetx')",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.10.4"
    },
    "vscode": {
      "interpreter": {
        "hash": "aa67ff675248b5ab29dcd2f00c1422844307085c8ca7c8ce7eddecd21b9c2975"
      }
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
